package crudfx.navigation;
import javax.swing.*;
import java.awt.event.*;
/**
 * @profile desktop
 * @author Sergey Surikov
 */
public class MenuLink extends MenuPad{
    public var text:String on replace {menuItem.setText(text);};
    public var action:function():Void;
    public var icon:javax.swing.Icon=null on replace{menuItem.setIcon(icon);};
    var menuItem:JMenuItem;
    override public function addPopUp(popup:JPopupMenu):Void{popup.add(menuItem);}
    override public function addMenu(menu:JMenu):Void{menu.add(menuItem);}
    init{
        menuItem=new JMenuItem();
        menuItem.setText(text);
        menuItem.setIcon(icon);
        menuItem.addActionListener(ActionListener{
                override function actionPerformed(e:ActionEvent){action();}}
            );
        }
    }
